package server.content.skills.fm;

import server.Server;
import server.game.players.Client;

public class GlobalFire {

	private final int x;
	private final int y;
	private final int expire;
	private int timer = -1;
	public boolean removeFire;
	private final int logId;
	private boolean isDead;
	private final Client c;

	public GlobalFire(final Client c, final int logId, final int x,
			final int y, final int expire) {
		this.c = c;
		this.x = x;
		this.y = y;
		this.expire = expire;
		this.logId = logId;
		timer = this.expire;
	}

	public void processFire() {
		if (getTimer() > 0) {
			setTimer(getTimer() - 1);
		} else if (getTimer() == 0) {
			removeFire = true;
			setTimer(-1);
		}
		if (removeFire && !isDead()) {
			final Client c = getClient();
			Server.itemHandler.createGroundItem(c, 592, getX(), getY(), 1, c.playerId);
			//c.getItems().createGroundItem(592, getX(), getY(), 1);
			Server.objectHandler.createAnObject(c, -1, getX(), getY());
			setDead(true);
		}
	}

	public void setDead(final boolean isDead) {
		this.isDead = isDead;
	}

	public Client getClient() {
		return c;
	}

	public boolean isDead() {
		return isDead;
	}

	public int getLogId() {
		return logId;
	}

	public int getTimer() {
		return timer;
	}

	public void setTimer(final int timer) {
		this.timer = timer;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getExpire() {
		return expire;
	}

}
